package com.syj.jsxjj.ui.login.presenter;/**
 * Created by Administrator on 2017/2/16 0016.
 */

import com.syj.jsxjj.base.BasePresenter;
import com.syj.jsxjj.http.HttpManager;
import com.syj.jsxjj.http.HttpSubscriber;
import com.syj.jsxjj.ui.login.contract.RegisterContract;
import com.syj.jsxjj.ui.my.bean.UserInfoBean;

import java.util.Map;

/**
 * Created by xiejingwen at 2017/2/16 0016
 */
public class RegisterPresenter extends BasePresenter<RegisterContract.View> implements RegisterContract.Presenter {
    private final String TYPE_REGISTER = "register";

    @Override
    public void toRegister(Map<String, String> params) {
        toSubscribe(HttpManager.getApi().register(params)
                , new HttpSubscriber<UserInfoBean>() {

                    @Override
                    protected void _onStart() {
                        mView.showLoading("注册中...");
                    }

                    @Override
                    protected void _onNext(UserInfoBean register) {
                        mView.registerSuccess(register);
                    }

                    @Override
                    protected void _onError(String message) {
                        mView.showErrorMsg(message, TYPE_REGISTER);
                    }

                    @Override
                    protected void _onCompleted() {
                        mView.stopLoading();
                    }
                });
    }
}
